const Com = require("./baseCom");
const D25 = require("./libs/ccc.25d");

cc.Class({
    extends: Com,

    ctor(){
        this._D25Engine = new D25( { target : this } );
        this.__inited = false;
    },

    init25D( params ){
        //if(this.__inited ) return this;
        this._D25Engine.init( params );
        this.__inited = true;
        return this;
    },

    setPosition25D( xr , yr , zr ){
        let possize = this._D25Engine.get25dPos( xr , yr , zr );
        let opacity = possize.opacity ? possize.opacity : 255;
        //console.log(possize.d2pos);
        this.node.setPosition( cc.v2(possize.d2pos.x , possize.d2pos.y) );

        this.node.zIndex = yr*10;
        
        // if(opacity>=255){
        //     cc.tween( this.node )
        //     .to( .02 , {opacity:opacity} )
        //     .start();
        // }else{
            this.node.opacity = opacity;
        // }
        
        this.setAttr("xr" , xr);
        this.setAttr("yr" , yr);
        this.setAttr("zr" , zr);

        this.onPosition && this.onPosition( possize , possize.size.w/this.node.width , possize.size.h/this.node.height  );
        $T.setNodeSize( this.node , [ possize.size.w , ] );
    }

});
